package com.ttuproject.ttu.service.serviceImpl;

import com.github.pagehelper.PageHelper;
import com.ttuproject.ttu.dao.DistributionTransformerTab;
import com.ttuproject.ttu.dao.InstallationAccount;
import com.ttuproject.ttu.dao.PoleChangeTab;
import com.ttuproject.ttu.dao.User;
import com.ttuproject.ttu.exception.Advice;
import com.ttuproject.ttu.exception.TTUException;
import com.ttuproject.ttu.mapper.TTUMapper.QueryStationMapper;
import com.ttuproject.ttu.mapper.TTUMapper.UserMapper;
import com.ttuproject.ttu.service.QueryStationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName QueryStationServiceImpl
 * @Description TODO
 * @Author cw
 * @Date 2021/12/6 11:40
 */
@Service
@Slf4j
public class QueryStationServiceImpl implements QueryStationService {

    @Autowired
    QueryStationMapper queryStationMapper;
    @Autowired
    UserMapper userMapper;

    @Override
    public List<InstallationAccount> queryrod(int pageNumber) {
        int pageSize = 10;
        PageHelper.startPage(pageNumber, pageSize);
        List<InstallationAccount> accountList = queryStationMapper.queryrod();
        System.out.println("accountList = " + accountList);
        if (accountList == null) {
            throw new TTUException(Advice.POLE_TRANSFORMER_AREA_ERROR);
        } else {
            return accountList;
        }
    }

    @Override
    public List<InstallationAccount> querybox(int pageNumber) {
        int pageSize = 10;
        PageHelper.startPage(pageNumber, pageSize);
        List<InstallationAccount> accountList = queryStationMapper.querybox();
        System.out.println("accountList = " + accountList);
        if (accountList == null) {
            throw new TTUException(Advice.BOX_TRANSFORMER_STATION_ERROR);
        } else {
            return accountList;
        }
    }

    @Override
    public List<InstallationAccount> querystation(int pageNumber) {
        int pageSize = 10;
        PageHelper.startPage(pageNumber, pageSize);
        List<InstallationAccount> accountList = queryStationMapper.querystation();
        System.out.println("accountList = " + accountList);
        if (accountList == null) {
            throw new TTUException(Advice.SUBSTATION_AREA_ERROR);
        } else {
            return accountList;
        }
    }

    @Override
    public List<InstallationAccount> queryDistributionstation(int pageNumber) {
        int pageSize = 10;
        PageHelper.startPage(pageNumber, pageSize);
        List<InstallationAccount> accountList = queryStationMapper.queryDistributionstation();
        System.out.println("accountList = " + accountList);
        if (accountList == null) {
            throw new TTUException(Advice.DISTRIBUTION_TRANSFORMER_AREA_ERROR);
        } else {
            return accountList;
        }
    }


    /**
     * @explain: 杆变查看详情
     * @author: cw
     * @date: 2021/12/7
     */
    @Override
    public PoleChangeTab detailedrod(String equipment_name) {
        PoleChangeTab poleChangeTab = queryStationMapper.detailedrod(equipment_name);
        if (poleChangeTab == null) {
            throw new TTUException(Advice.SELECT_DETAILEDROD_ERROR);
        } else {
            return poleChangeTab;
        }
    }

    @Override
    public DistributionTransformerTab detailed_distribution(String equipment_name) {
        DistributionTransformerTab distribution = queryStationMapper.detailed_distribution(equipment_name);
        if (distribution == null) {
            throw new TTUException(Advice.SELECT_DETAILED_DISTRIBUTION_ERROR);
        } else {
            return distribution;
        }
    }

    /**
     * 杆变台区搜索框
     * @param equipment_name
     * @return
     */
    @Override
    public List<InstallationAccount> findrod(String equipment_name) {
        //查询条件：
        List<InstallationAccount> findrod = queryStationMapper.findrod(equipment_name);
        log.info("杆变台区搜索框查询成功成功");
        return findrod;
    }

    /**
     * 箱变台区搜索框
     * @param equipment_name
     * @return
     */
    @Override
    public List<InstallationAccount> findBox(String equipment_name) {
        //查询条件：
        List<InstallationAccount> findBox = queryStationMapper.findbox(equipment_name);
        log.info("箱变台区搜索框查询成功成功");
        return findBox;

    }

    /**
     * 站变台区搜索框
     * @param equipment_name
     * @return
     */
    @Override
    public List<InstallationAccount> findStation(String equipment_name) {
        //查询条件：
        List<InstallationAccount> findStation = queryStationMapper.findstation(equipment_name);
        log.info( "站变台区搜索框查询成功成功");
        return findStation;
    }

    /**
     * 配变台区搜索框
     * @param equipment_name
     * @return
     */
    @Override
    public List<InstallationAccount> findDistribution(String equipment_name) {
        //查询条件：
        List<InstallationAccount> findDistribution = queryStationMapper.findDistributionstation(equipment_name);
        log.info("配变台区搜索框查询成功成功");
        return findDistribution;
    }
}
